﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace msgExchange
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //
            CSysSettingMananger settingManager_ = new CSysSettingMananger();
            //
            if (!settingManager_.load())
            {
                MessageBox.Show("Fail to load system setting.", "Error");
                return;
            }
            //
            bool retryLogon = false;
            do
            {
                retryLogon = false;

                bool logonOK = false;
                frmLogon f = new frmLogon(settingManager_);
                DialogResult drTemp = f.ShowDialog();
                if (drTemp == DialogResult.OK)
                {
                    Application.Run(new frmMain(settingManager_));
                }
                else if (drTemp == DialogResult.Ignore)
                {
                    retryLogon = true;
                    new frmSettings(settingManager_).ShowDialog();
                    continue;
                }

                if (!logonOK)
                {
                    Application.Exit();
                    return;
                }

            } while (retryLogon);



        }
    }
}